﻿
@{
    ViewBag.Title = "SysDepartmentBindingIndex";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建</a>
        </div>
        <div class="btn-group">
            <a id="NF-edit" class="btn btn-primary dropdown-text" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改信息</a>
        </div>
        <div class="btn-group">
            <a id="NF-delete" class="btn btn-primary dropdown-text" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除信息</a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="医生名称" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
</div>

<script>
    $(function () {
        initControl();
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/SystemManage/SysDepartmentBinding/GetSysDepartmentBindingList",
            height: 400,
            colModel: [
                { label: 'bddm', name: 'bddm', hidden: true },
                { label: '科室', name: 'ksmc', width: 100, algin: 'left' },
                { label: '姓名', name: 'xm', width: 100, algin: 'left' },
                {
                    label: '性别', name: 'xb', width: 100, algin: 'left',
                    formatter: function (cellvalue) {
                        if (cellvalue) {
                            return "男";
                        } else {
                            return "女";
                        }
                    }
                },
                { label: '身份证', name: 'zjh', width: 100, algin: 'left' }
            ]
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() }, url: "/SystemManage/SysDepartmentBinding/GetSysDepartmentBindingList"
            }).trigger('reloadGrid');
        })
    }

    function initControl() {

    }

    function btn_add() {
        $.modalOpen({
            id: "FormFIEdit",
            title: "新增科室人员绑定",
            url: "/SystemManage/SysDepartmentBinding/Form",
            width: "700px",
            height: "300px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    //修改
    function btn_edit() {
        var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
        if (!(seleRowid)) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        var bddm = $("#gridList").jqGridRowValue().bddm;
        $.modalOpen({
            id: "FormFIEdit",
            title: "修改科室人员绑定",
            url: "/SystemManage/SysDepartmentBinding/Form?bddm=" + bddm,
            width: "700px",
            height: "300px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    //删除
    function btn_delete() {
        var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
        if (!(seleRowid)) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        var bddm = $("#gridList").jqGridRowValue().bddm;
        $.deleteForm({
            url: "/SystemManage/SysDepartmentBinding/DeleteForm",
            param: { bddm: bddm },
            success: function () {
                $("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>

